/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.controlador;

import br.com.modelo.NfeConfiguracao;
import br.com.nfe.StatusServico;
import com.sun.codemodel.JOp;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.swing.JOptionPane;
import util.JPAUtil;

/**
 *
 * @author Gilberto
 */
@ManagedBean
@ViewScoped
public class StatusServicoControler {

    private NfeConfiguracao nfeConfig;

    @PostConstruct
    private void init() {
        nfeConfig = new NfeConfiguracao();
    }

    public void getStatusServico() {
        nfeConfig = JPAUtil.buscarPorId(NfeConfiguracao.class, 1);
        if (nfeConfig != null) {
            String caminhoCertificado = nfeConfig.getCaminhoCertificado()+nfeConfig.getCertificadoDigital();
            char[] senha = (char[]) nfeConfig.getSenhaCertificado().toCharArray();

            StatusServico statusNfe = new StatusServico();
//            JSFUtil.addMessageSucesso(statusNfe.verificaStatusServico(caminhoCertificado, senha) + "Status do serviço NF-e");
            JOptionPane.showMessageDialog(null, statusNfe.verificaStatusServico(caminhoCertificado, senha) + "Status do serviço NF-e");
        }
    }
    public static void main(String[] args) {
       StatusServicoControler v = new StatusServicoControler();
       v.getStatusServico();
    }
}
